package com.hhwy.frame.server.serviceImpl;

import com.hhwy.frame.server.AppServer;
import com.hhwy.framework.persistent.DAO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 创建人: wangpengfei
 * 创建日期: 2017/10/26
 * 功能描述:
 */

@Service
public class AppServerImpl implements AppServer{
    Logger log = LoggerFactory.getLogger(AppServerImpl.class);
    @Autowired
    public DAO<?> dao;
    public List<Map> getProjectList() {
        Map parmers = new HashMap();
        List<Map> list = (List<Map>)dao.getBySql("app.sql.getProjectList",parmers);
        List<Map> newArrayList  = new ArrayList<>();
        for(int i = 0; i<list.size();i++){
            Map map = new HashMap();
            map.put("uid",list.get(i).get("id").toString());
            if(i>=6){
                map.put("imgPath","widget://res/image/demo"+(i-6+1)+".png");
            }else{
                map.put("imgPath","widget://res/image/demo"+(i+1)+".png");
            }
            map.put("title",list.get(i).get("manager")==null?"张诚":list.get(i).get("manager").toString());
            map.put("subTitle",list.get(i).get("project_name")==null?"":list.get(i).get("project_name").toString());
            map.put("remark",list.get(i).get("project_code")==null?"":list.get(i).get("project_code").toString());
            map.put("icon","");
            newArrayList.add(map);
        }
        return newArrayList;
    }

    public List<Map> getUserList() {
        Map parmers = new HashMap();
        List<Map> list = (List<Map>)dao.getBySql("app.sql.getUserList",parmers);
        List<Map> newArrayList  = new ArrayList<>();
        for(int i = 0; i<list.size();i++){
            Map map = new HashMap();
            map.put("uid",list.get(i).get("id").toString());
            if(i>=6){
                map.put("imgPath","widget://res/image/demo"+(i-6+1)+".png");
            }else{
                map.put("imgPath","widget://res/image/demo"+(i+1)+".png");
            }
            map.put("title",list.get(i).get("manager")==null?"张诚":list.get(i).get("manager").toString());
            map.put("subTitle",list.get(i).get("project_name")==null?"":list.get(i).get("project_name").toString());
            map.put("remark",list.get(i).get("project_code")==null?"":list.get(i).get("project_code").toString());
            map.put("icon","");
            newArrayList.add(map);
        }
        return newArrayList;
    }


    public List<Map> getMenuList() {
        Map parmers = new HashMap();
        List<Map> list = (List<Map>)dao.getBySql("app.sql.getMenuList",parmers);

        return list;
    }

}
